****************************************************************************
* File-Nale: 	codes_june.do
* Date:		 	02/01/2021
* Author: 		Fred Batista and Felipe Nunes
* Purpose: 		Analysis of March survey data
* Data used: 	datajune.dta
* Data Output:	None	*/
****************************************************************************

***** RECODES

**** IVS

* knows someone who had coronavirus

encode P11, gen(covidprox)

recode covidprox (1=0) (2=.) (3=1)

* concern about COVID

encode P7, gen (worriedcov01)

replace worriedcov01= (worriedcov -1)/4

* media exposure

encode P34, gen(mediaexp)

recode mediaexp (1=3) (2=2)(3=4) (4=0) (5=1)

replace mediaexp = mediaexp/4


**** MODERATOR

encode P19, gen(resp)

recode resp (2 3 4=0) (1=1) (5=2)

gen respbolso = resp

recode respbolso (2=1) (else=0)

gen respcong = resp

recode respcong (1=1) (else=0)


**** EXPERIMENT

encode P20, gen(treat)

recode treat (1=1) (2=0)


*** DEPENDENT VARIABLE: BOLSONARO OPINION

* evaluation of bolsonaro�s job performance

* pre-treatment

encode P4, gen(approval1)

recode approval1 (1=4) (2=.) (3=0) (4=2) (5=3) (6=1) (7=5) 

replace approval1 = approval1/5

* post-treatment

encode P22, gen(approval2)

recode approval2 (1=4) (2=.) (3=0) (4=2) (5=3) (6=1) (7=5) 

replace approval2 = approval2/5

* diff_approval

gen diff_approval = approval2 - approval1

*** DEPENDENT VARIABLE: CONGRESSO OPINION

* pre-treatment

encode P6, gen(cong1)

recode cong1 (1=4) (2=.) (3=0) (4=2) (5=3) (6=1) (7=5) 

replace cong1 = cong1/5

* post-treatment

encode P23, gen(cong2)

recode cong2 (1=4) (2=.) (3=0) (4=2) (5=3) (6=1) (7=5) 

replace cong2 = cong2/5

* diff_cong

gen diff_cong = cong2 - cong1


*** DEPENDENT VARIABLE: SUPPORT FOR COUP

encode P28, gen(closecong)

recode closecong (1=.5) (2=0) (3=1)

encode P29, gen(closestf)

recode closestf (1=.5) (2=0) (3=1)



*** OTHER OPINIONS: CONCERN ABOUT BRAZIL

* concern versus others

encode P1, gen(concernbr)

recode concernbr (4=1) (else=0)

* concern separated from revolt versus others

encode P1, gen(concernbr2)

recode concernbr2 (4=2) (5=1) (else=0)


*** OTHER OPINIONS: COVID-RELATED

* main fear (fear of economy =1; fear of disease=0)

encode P8, gen(fearcov)

recode fearcov (1=1) (2=0) (3 4=.)

* social distancing view (maintain or keep for the elderly=1; suspend =0)

encode P9, gen(socdistkeep)

recode socdistkeep (1=0.5) (2=1) (3=.) (4=0)

* keep business shut (maintain indefinitely or for 15days = 1; open=0)

encode P10, gen(businessshut)

recode businessshut (1=1) (2=.) (3=0) (4=0.5)

* measures

polychoric businessshut socdistkeep

gen measures2 = (businessshut + socdistkeep)/2


*** OPINIONS ABOUT BRAZIL

* brazil�s getting better or worse (worse, nowhere and DK, better)

encode P2, gen(brabetterworse)

recode brabetterworse (1=2) (2=1) (3=0) (4=1)

gen brabetterworse01 = brabetterworse/2


*** OTHER OPINIONS ABOUT BOLSONARO

* bolsonaro�s admin better or worse than expected (Dk combined as middle)

encode P5, gen(bolsoexp)

recode bolsoexp (1=2) (2 3=1) (4=0)

gen bolsoexp01 = bolsoexp/2

* 2018 vote (null and absent as neutral category)

encode P37, gen(vote18)

gen haddadvoter = vote18

recode haddadvoter (2=1) (else=0)

gen bolsovoter = vote18

recode bolsovoter (3=1) (else=0)

* 2022 vote (DK as neutral category)

encode P41, gen(vote22)

gen haddadfuture = vote22

recode haddadfuture (2=1) (else=0)

gen bolsofuture = vote22

recode bolsofuture (3=1) (else=0)

* general feelingsabout bolsonaro (similar to March)

polychoric approval1 bolsoexp01 bolsovoter bolsofuture

alpha approval1 bolsoexp01 bolsovoter bolsofuture, std

gen bolsoeval = (approval1 + bolsoexp01 + bolsovoter + bolsofuture)/4


* CONTROLS

* most trustworthy information source

encode P35, gen(infosource)

gen sourcetv = infosource

recode sourcetv (1=1) (else=0)

gen sourcetv2 = infosource

recode sourcetv2 (1 2 3 4=1) (else=0)

gen sourcenet = infosource

recode sourcenet (5 6=1) (else=0)

gen mediachoice = infosource

recode mediachoice (1=1) (5 6=2) (else=0)

* religion

encode P33, gen(religion)

gen catholic = religion

recode catholic (1=1)(else=0)

gen protestant = religion

recode protestant (2 6=1) (else=0)

* ideologia (higher is right)

encode P36, gen(ideo)

recode ideo (1=0) (2=1) (3=10) (4=2) (5=3) (6=4) (7=5) (8=6) (9=7) (10=8) (11=9)

gen ideo01 = ideo/10

* income

* continuous

encode P32, gen(income)

recode income (1=0) (2=6) (3=1) (4=5) (5=2) (6=3) (7=4) (8=7)  (9=.)

gen income01 = (income)/7

* sex (male=1)

encode AV, gen(male)

replace male = male - 1

* age

encode AW, gen(age)

gen age01 = (age-1)/58

* region

encode AX, gen(region)

* social class

encode AY, gen(class)

recode class (6=.)

replace class = 5 - class

gen class01= class/4


*** DESCRIPTIVES

summarize worriedcov01 measures fearcov bolsoeval 1.mediachoice 2.mediachoice 0.mediachoice age01 ideo01 catholic protestant income01 male 1.region 2.region 3.region 4.region 5.region 

pwcorr concernbr worriedcov01 measures fearcov, sig


*** ANALYSES

* correlates of mediachoice

mprobit mediachoice bolsoeval age01 ideo01 catholic protestant income01 male i.region, base(0)


* corelates of concern

reg worriedcov01 bolsoeval age01 i.mediachoice ideo01 catholic protestant income01 male i.region

margins, dydx(mediachoice)

reg worriedcov01 c.bolsoeval##i.mediachoice age01  ideo01 catholic protestant income01 male i.region

margins, at(bolsoeval=(0(.1)1) mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) plot2(mcolor(gs12) connect(direct) lcolor(gs12)) ci2(lcolor(gs12) msize(vtiny)) plotdimensions(,label("TV" "Internet")) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(.3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title("Concern About Covid-19", color(black) size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(june1)


* correlates of support for measures

reg measures bolsoeval age01 i.mediachoice ideo01 catholic protestant income01 male i.region

margins, dydx(mediachoice)


reg measures c.bolsoeval##i.mediachoice bolsoeval age01  ideo01 catholic protestant income01 male i.region

margins, at(bolsoeval=(0(.1)1) mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) plot2(mcolor(gs12) connect(direct) lcolor(gs12)) ci2(lcolor(gs12) msize(vtiny)) plotdimensions(,label("TV" "Internet")) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(.3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title("Support for Measures", color(black) size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8)  saving(june2)

* combining graphs

grc1leg june1.gph june2.gph, title({bf:June}, size(vlarge)) plotregion(style(none)) graphregion(color(white)) rows(1) iscale(1) name(june)

graph display june, ysize(6) xsize(10)



* correlates of economic fear

probit fearcov bolsoeval i.mediachoice age01 ideo01 catholic protestant income01 male i.region

margins, at(mediachoice=(1(1)2))

marginsplot, plot1(mcolor(black) connect(none)) ci1(lcolor(black) msize(vtiny)) ytitle("", height(7)) xtitle(" ") xlabel(0.5 " " 1 "TV" 2 "Internet" 2.5 " ", noticks labsize(large)) title({bf:June}, size(large)) ylabel(0(.1).50,nogrid) yscale(noextend)  plotregion(style(none)) graphregion(color(white)) ysize(8) xsize(8) saving(econ1june)

margins, at(bolsoeval=(0(.1)1))

marginsplot, plot1(mcolor(black) connect(direct) lcolor(black)) ci1(lcolor(black) msize(vtiny)) ytitle("")  xtitle(Bolsonaro Support, size(medlarge) margin(medsmall)) xlabel(0 "Lowest" .1 " " .2" " .3 " " .4 " " .5 " " .6 " " .7 " " .8 " " .9 " " 1 "Highest", labsize(medium)) ylabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1" , nogrid) title({bf:June}, size(large)) legend(col(2) pos(6) ring(1) region(lstyle(none))) yscale(noextend) xscale(noextend) plotregion(style(none) margin(medlarge)) graphregion(color(white) margin(medlarge)) ysize(8) xsize(8) saving(econ2june)



*******


*** replacing info source by media choice

reg worriedcov01 c.bolsoeval##i.infosource age01  ideo01 catholic protestant income01 male i.region

reg measures c.bolsoeval##i.infosource bolsoeval age01  ideo01 catholic protestant income01 male i.region


***** END OF CODE
